package com.lance.answer.gui.answer.gk.answer.lms.batch;

import com.google.common.collect.Maps;
import com.lance.answer.gui.answer.gk.answer.lms.batch.dto.LmsWatchDTO;
import com.lance.answer.gui.answer.gk.answer.lms.batch.task.LmsSaveUnVideoTask;
import com.lance.answer.gui.answer.gk.answer.lms.util.LmsUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.concurrent.LinkedBlockingDeque;

/**
 * <p>拿到所有课程的链接 2022-4-30<p>
 * <p>
 * <p>4-28 FIXME 课程讨论区的的帖子的ID还没获取到？？？？？？？？？？？？？？？？？？
 * <p>
 * <p>
 * 工程经济,size:1
 *
 * @author : fengx
 * @since JDK8.0
 * create by fengx on 2022/4/19 14:47
 */
@Slf4j
public class LmsSaveUnVideotmmmmp {

    /**
     * List<Long> courseIds = Lists.newArrayList(
     * 14847L,//人力资源管理
     * 14920L,//资源与运营管理
     * 14953L,//市场营销学
     * 14954L,//管理学基础
     * 15062L,// 毛泽东思想和中国特色社会主义理论体系概论
     * 16502l,//企业现场管理基础
     * 19180l//职业生涯规划（1）
     * );
     *
     * @param args
     * @throws Exception
     */

    public static void main(String[] args) throws Exception {


        int sync = 1;

        LinkedBlockingDeque<LmsWatchDTO> watchQueue = new LinkedBlockingDeque<>();

        InputStream inputStream2 = new FileInputStream("libs//2022秋//fengx.user");
        List<String> userString = IOUtils.readLines(inputStream2, "utf-8");

        for (String user : userString) {
            String[] strs = user.split(",");
            String userCode = strs[0];
            String pwd = strs[1];
            LmsWatchDTO lmsWatchDTO = new LmsWatchDTO();
            lmsWatchDTO.setUsername(userCode);
            lmsWatchDTO.setPassword(pwd);
//            if(!LmsUtil.getVip().contains(userCode)){
//                continue;
//            }
            if(!userCode.equals("2213001407081")){
                continue;
            }
        //    if(!"2251001204872".equals(userCode)){
//            getUserCourseMap.put(16796l, "法律文化");
//            getUserCourseMap.put(13964l, "实用法律基础");
//            lmsWatchDTO.setCourseMap(getUserCourseMap);

            Map<Long, String> courseMap =    LmsUtil.getUserCourseMap(userCode);
//            courseMap.clear();
//            courseMap.put(30000004842L,"消费者权益保护法");
            lmsWatchDTO.setCourseMap(courseMap);
            watchQueue.add(lmsWatchDTO);
        }

        for (int i = 1; i <= sync; i++) {
            Thread answerThread = new LmsSaveUnVideoTask("d:\\ynouAutoStudy\\chromedriver.exe", watchQueue);
            //log.info("加载课程ID：{} 名称：{} ", openCourseId,subjectName);
            answerThread.setName("答题线程--" + i);
            answerThread.start();
        }


    }


}




